package com.shop.ken.controller.login;

import com.github.pagehelper.util.StringUtil;
import com.shop.ken.common.base.controller.AbstractBaseController;
import com.shop.ken.entity.model.AmsUser;
import com.shop.ken.service.AmsUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 项目名称：shop-server
 * 文件名称：LoginController
 * 日期：2017/9/7
 * Copyright ©2017, 广州职赢未来信息科技有限公司 All Rights Reserved.\
 * <p>
 * <p>
 * 功能描述：登录控制层
 * 创建人: 霍梓潮
 * 创建时间：2017/9/7
 **/
@RestController
@RequestMapping("/login")
public class LoginController extends AbstractBaseController {

    @Autowired
    private AmsUserService amsUserService;

    @GetMapping("/get/{uuid}")
    public String Login(@PathVariable("uuid") String uuid, String username, String password){
        if(StringUtil.isEmpty(username)){
            return returnInfo(false, "帐号不能为空！");
        }
        if(StringUtil.isEmpty(password)){
            return returnInfo(false, "密码不能为空！");
        }
        AmsUser user = amsUserService.getUser(username, password);
        if(user==null){
            return returnInfo(false, "帐号或密码错误！");
        }
        return returnInfo(true,"success");
    }
}
